function [fprojs,samp_space,samp_pos,f] = fftfilter(projs,det_space,det_pos)

% Filtering of projection using FFT
%
% [fprojs,samp_space,samp_pos,f] = fftfilter(projs,det_space,det_pos)
%
% INPUTS
% projs = projections obtained from calcproj
% det_space = Spacing of detectors along the projection
% det_pos = detector positions in [-L/2,L/2]
%
% OUTPUTS
% fprojs = filtered projections
% samp_space = Spacing of samples in the filtered projection
% samp_pos = sample positions in the filtered projection
% f = filter freq domain samples
%
% Developed by	Srikrishna Bhashyam and Andy Doran
%               Rice University
% 		March 1, 1999
%

num_dets = length(det_pos);
samp_space = det_space;
samp_pos = det_pos;

flength = num_dets*16;
nzsamp = round(num_dets*16*7/16);

f = [0:1/flength:1];
f = f(1:flength);
x = find(f > 0.5);
f(x) = 1 - f(x);
f = f/det_space;

f = [f(1:nzsamp) zeros(1,flength - 2*nzsamp) f(flength - nzsamp + 1:flength)];

[xs,ys] = size(projs);
fprojs = zeros(xs,ys);
for i = 1:xs
fprojszp = fft([projs(i,:) zeros(1,flength - length(projs(i,:)))]).*f;
fprojszp = real(ifft(fprojszp));
fprojs(i,:) = fprojszp(1:length(projs(i,:)));
end

%subplot(211);
%plot(abs(fft([projs(1,:) zeros(1,flength - length(projs(1,:)))])));
%subplot(212);
%plot(fprojs(1,:));
%pause







